#!/bin/bash

mysql_password=123456
mysql_port=3306
mysql_db=devops

#安装docker-compose
#wget https://github.com/docker/compose/releases/download/1.24.1/docker-compose-Linux-x86_64
mv docker-compose /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose

#安装mysql
docker pull mysql:5.7
docker run -d --name devops-mysql -p $mysql_port:3306 -v /data/mysql:/var/lib/mysql --restart=always  -e MYSQL_ROOT_PASSWORD=$mysql_password -e TZ=Asia/Shanghai mysql:5.7 --character-set-server=utf8
sleep 20
docker exec devops-mysql mysql -uroot -p$mysql_password -P $mysql_port -e "CREATE DATABASE $mysql_db DEFAULT CHARACTER SET utf8;"

#运行服务
docker-compose up -d
